/*
 * =====================================================================================
 *
 *       Filename:  main.cpp
 *
 *    Description:  main.cpp
 *
 *         Author:  Younghyun Jo
 *   Organization:  Master Student
 *                  Computer Systems and Platforms Laboratory
 *                  Seoul National University
 *
 * =====================================================================================
 */
#include "epcc.h"
#include "stack.h"

int main(int argc, char* argv[])
{
  if (argv[1]==NULL || argv[2]==NULL || argv[3]==NULL || argv[4]==NULL) {
    printf("[Usage] ./test_stack [numParticipants] [pushRatio] [numOperations] [Operation interval]\n");
    return 1;
  }

  int numParticipants = atoi(argv[1]);
  double pushRatio = atof(argv[2]);
  uint64_t numOperations = atol(argv[3]);
  long long intervalOperation = atol(argv[4]);
  printf("numParticipants: %d pushRatio: %lf numOperations: %lu intervalOperation: %lu\n",
          numParticipants, pushRatio, numOperations, intervalOperation);


  printf("\n[CCoarseGrainedLockStack Benchmark]\n");
  EPCC<CCombTreeStack> epcc(numParticipants, pushRatio, numOperations, intervalOperation);
  epcc.measureCStackPerformance();

//  /* Benchmark for CCoarseGrainedLockStack */
//  printf("\n[CCoarseGrainedLockStack Benchmark]\n");
//  EPCC<CCoarseGrainedLockStack> epcc(numParticipants, pushRatio, numOperations, intervalOperation);
//  epcc.measureCStackPerformance();
//
//  /* Benchmark for CLockFreeStack */
//  printf("\n[CLockFreeStack Benchmark]\n");
//  EPCC<CLockFreeStack> epcc2(numParticipants, pushRatio, numOperations, intervalOperation);
//  epcc2.measureCStackPerformance();
//
//  /* Benchmark for CEliminationBackoffStack */
//  if (argv[5]!=NULL && argv[6]!=NULL) {
//    int capacity = atoi(argv[5]);
//    long long timeout = atol(argv[6]);
//
//    printf("capacity: %d timeout: %lu\n", capacity, timeout);
//    printf("\n[CEliminationBackoffStack Benchmark]\n");
//    EPCC<CEliminationBackoffStack> epcc3(numParticipants, pushRatio, numOperations, intervalOperation, capacity, timeout);
//    epcc3.measureCStackPerformance();
//  } else {
//    printf("\n[CEliminationBackoffStack Benchmark]\n");
//    EPCC<CEliminationBackoffStack> epcc3(numParticipants, pushRatio, numOperations, intervalOperation);
//    epcc3.measureCStackPerformance();
//  }

  return 0;
}

